<template>
  <div class="demo">
    <h2 class="name">学校名称：{{ name }}</h2>
    <h2>学校地址：{{ address }}</h2>
  </div>
</template>

<script>
export default {
  name: "Student",
  data() {
    return {
      name: "重庆大学",
      address: "重庆",
    };
  },
  mounted() {
    this.$bus.$on("hello", (data) => {
      console.log("我是School组件，收到了数据", data);
    });
  },
  beforeDestroy() {
    this.$bus.$off("hello");
  },
};
</script>

<style scoped lang="less">
.demo {
  background-color: palevioletred;
  color: white;
  .name {
    color: palegreen;
  }
}
</style>
